(function ($) {
    "use strict"; // Start of use strict  

    /*------------------------------------------------
     * Preloader 
    ------------------------------------------------*/
    $(window).load(function () {
        //$('#loading').fadeOut();
        //$('#preloader').delay(300).fadeOut('slow');
        //$('#modal1').modal('show');
    });
    /*------------------------------------------------
     * Affix   
    ------------------------------------------------*/
    $(".dropdown-menu li a").on('click', function () {
        var selText = $(this).text();
        $(this).parents('.btn-group').find('.dropdown-toggle').html(selText + ' <span class="caret"></span>');
    });

    //$("#btnSearch").on('click', function () {
    //    //alert($('.btn-select').text() + ", " + $('.btn-select2').text());
    //});

    // jQuery for page scrolling feature - requires jQuery Easing plugin
    $('a.page-scroll').on('click', function (event) {
        var $anchor = $(this);
        $('html, body').stop().animate({
            scrollTop: ($($anchor.attr('href')).offset().top - 0)
        }, 1250, 'easeInOutExpo');
        event.preventDefault();
    });

    // Highlight the top nav as scrolling occurs
    $('body').scrollspy({
        target: '.scroll',
        offset: 0
    })

    // Offset for Main Navigation
    $('#mainNav').affix({
        offset: {
            top: 100
        }
    })

    // hide #back-top first
    $("#back-top").hide();

    // fade in #back-top
    $(function () {
        $(window).scroll(function () {
            if ($(this).scrollTop() > 100) {
                $('#back-top').fadeIn();
            } else {
                $('#back-top').fadeOut();
            }
        });

        // scroll body to 0px on click
        $('#back-top a').on('click', function () {
            $('body,html').animate({
                scrollTop: 0
            }, 800);
            return false;
        });
    });
	/*------------------------------------------------
 * select options    
------------------------------------------------*/
    $(document).ready(function () {
        $(".btn-select").each(function (e) {
            var value = $(this).find("ul li.selected").html();
            if (value != undefined) {
                $(this).find(".btn-select-input").val(value);
                $(this).find(".btn-select-value").html(value);
            }
        });
    });

    $(document).on('click', '.btn-select', function (e) {
        e.preventDefault();
        var ul = $(this).find("ul");
        if ($(this).hasClass("active")) {
            if (ul.find("li").is(e.target)) {
                var target = $(e.target);
                target.addClass("selected").siblings().removeClass("selected");
                var value = target.html();
                $(this).find(".btn-select-input").val(value);
                $(this).find(".btn-select-value").html(value);
            }
            ul.hide();
            $(this).removeClass("active");
        }
        else {
            $('.btn-select').not(this).each(function () {
                $(this).removeClass("active").find("ul").hide();
            });
            ul.slideDown(300);
            $(this).addClass("active");
        }
    });

    $(document).on('click', function (e) {
        var target = $(e.target).closest(".btn-select");
        if (!target.length) {
            $(".btn-select").removeClass("active").find("ul").hide();
        }
    });

    /*------------------------------------------------
     * Initialize WOW.js Scrolling Animations 
    ------------------------------------------------*/

    new WOW().init();


    /*------------------------------------------------
     * owlCarousel    
    ------------------------------------------------*/
    $(".deals-wk").owlCarousel({

        navigation: true, // Show next and prev buttons
        paginationSpeed: 400,
        singleItem: true

        // "singleItem:true" is a shortcut for:
        // items : 1, 
        // itemsDesktop : false,
        // itemsDesktopSmall : false,
        // itemsTablet: false,
        // itemsMobile : false

    });
    $(".deals-wk2").owlCarousel({

        navigation: true, // Show next and prev buttons
        paginationSpeed: 400,
        singleItem: true

        // "singleItem:true" is a shortcut for:
        // items : 1, 
        // itemsDesktop : false,
        // itemsDesktopSmall : false,
        // itemsTablet: false,
        // itemsMobile : false

    });

})(jQuery); // End of use strict

